home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1990 / 05 / vtest.cpp < prev    next >
Text File  |  1990-08-06  |  2KB  |  39 lines

  1. #include "vint.cpp"
  2.  
  3. main ()
  4. {
  5.     const int size = 5;
  6.     int result;
  7.     int i;
  8.     vint x = (long)size;      //array of "size" ints
  9.  
  10.     // load each element of the array with its own index
  11.  
  12.     // then read the array back to verify
  13.  
  14.     for (i=size; --i >= 0; x[i] = i) 
  15.         ;
  16.  
  17.     for (i=size; --i >= 0; )
  18.         if ( (result = x[i]) == i )
  19.             cout << "x[" << i << "]==" << result << "\n";
  20.  
  21. // legal operators----------------->|               |<-----------
  22.     cout << "x[3] = 3    = " <<     ( x[3]   = 3     )   << "\n" ;
  23.     cout << "x[3]        = " <<     ( (int)x[3]      )   << "\n" ;
  24.     cout << "x[3] + 5    = " <<     ( x[3]   + 5     )   << "\n" ;
  25.     cout << "x[3] - 5    = " <<     ( x[3]   - 5     )   << "\n" ;
  26.     cout << "x[3] / 5    = " <<     ( x[3]   / 5     )   << "\n" ;
  27.     cout << "x[3] * 5    = " <<     ( x[3]   * 5     )   << "\n" ;
  28.     cout << "5    + x[3] = " <<     ( 5      + x[3]  )   << "\n" ;
  29.     cout << "5    - x[3] = " <<     ( 5      - x[3]  )   << "\n" ;
  30.     cout << "5    * x[3] = " <<     ( 5      * x[3]  )   << "\n" ; 
  31.     cout << "5    / x[3] = " <<     ( 5      / x[3]  )   << "\n" ; 
  32.     cout << "x[3] + x[3] = " <<     ( x[3]   + x[3]  )   << "\n" ;
  33.     cout << "x[3] - x[3] = " <<     ( x[3]   - x[3]  )   << "\n" ;
  34.     cout << "x[3] * x[3] = " <<     ( x[3]   * x[3]  )   << "\n" ;
  35.     cout << "x[3] / x[3] = " <<     ( x[3]   / x[3]  )   << "\n" ;
  36.     cout << "++x[3]      = " <<     ( ++x[3]         )   << "\n" ;
  37.     cout << "--x[3]      = " <<     ( --x[3]         )   << "\n" ;
  38. }
  39.